/**
 * 
 */
package com.nwpusp.display.resmgr;

import com.nwpusp.display.MainActivity;
import com.nwpusp.display.views.components.Animal;

import android.util.Log;
import android.view.View;
import android.widget.CalendarView;

/**
 * @author JustinCao
 *
 */
public class AnimalViewResManager extends ViewResourceManager {

	@Override
	public View allocView(Object[] param) {
		return new Animal((MainActivity)param[0], ((Integer)param[1]).intValue(),
				((Integer)param[2]).intValue(), ((Integer)param[3]).intValue(), (String)param[4]);
	}

	@Override
	protected View searchView(Object[] param) {
		if(isEmpty())
			return null;
		Animal ani = null;
		for(Object obj : this) {
			ani = (Animal)obj;
			Log.d("Search Resourse Name", ani.getName() + " " + (String)param[4]);
			if(ani.getName().equals((String)param[4]) && ani.getIndex() == ((Integer)param[2]).intValue()) {
				this.remove(ani);
				break;
			}
			else {
				ani = null;
			}
		}
		if(ani != null) {
			ani.setStatus(((Integer)param[3]).intValue());
			return ani;
		}
		return null;
	}
}
